package com.nidu.demo.mail;

import com.alibaba.cola.dto.MultiResponse;
import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.nidu.demo.mail.api.SysMailAccountService;
import com.nidu.demo.mail.dto.*;
import com.nidu.demo.mail.executor.command.*;
import com.nidu.demo.mail.executor.query.*;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Set;

/**
 * 邮件账号服务实现类
 *
 * @author auto
 */
@Service
@RequiredArgsConstructor
public class SysMailAccountServiceImpl implements SysMailAccountService {

    private final MailAccountAddCmdExe addCmdExe;
    private final MailAccountUpdateCmdExe updateCmdExe;
    private final MailAccountDeleteCmdExe deleteCmdExe;
    private final MailAccountSingleQryExe singleQryExe;
    private final MailAccountListQryExe listQryExe;
    private final MailAccountPageQryExe pageQryExe;

    @Override
    public SingleResponse<MailAccountCO> add(MailAccountAddCmd cmd) {
        return addCmdExe.execute(cmd);
    }

    @Override
    public SingleResponse<MailAccountCO> update(MailAccountUpdateCmd cmd) {
        return updateCmdExe.execute(cmd);
    }

    @Override
    public Response delete(Long id) {
        return deleteCmdExe.execute(id);
    }

    @Override
    public Response delete(Set<Long> ids) {
        return deleteCmdExe.execute(ids);
    }

    @Override
    public SingleResponse<MailAccountCO> getById(Long id) {
        return singleQryExe.execute(id);
    }

    @Override
    public MultiResponse<MailAccountCO> list(MailAccountListQry qry) {
        return listQryExe.execute(qry);
    }

    @Override
    public PageResponse<MailAccountCO> page(MailAccountPageQry qry) {
        return pageQryExe.execute(qry);
    }

}
